﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TestOnlineProject.Models.Entities;

namespace TestOnlineProject.Models.DataAccess
{
    public class TestQuestionDAO
    {
        TestOnlineDBEntities db = new TestOnlineDBEntities();

        public List<TestQuestion> SelectByTestId(int testId)
        {
            try
            {
                var testQuestions = (from t in db.TestQuestions where t.TestId == testId select t).ToList();
                return testQuestions;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public int Insert(TestQuestion testQuestion)
        {
            try
            {
                db.TestQuestions.AddObject(testQuestion);
                int result = db.SaveChanges();
                return result;
            }
            catch (Exception)
            {
                throw;
            }
        }
        public List<TestQuestion> SelectByQuestionId(int questionId)
        {
            try
            {
                var testQuestions = (from t in db.TestQuestions where t.QuestionId == questionId select t).ToList();
                return testQuestions;
            }
            catch (Exception)
            {
                throw;
            }
        } 
    }
}